Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop in DNS parsing #38

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

dgmcdona
Copy link
Contributor

@dgmcdona dgmcdona commented Dec 2, 2024

The primary goal of this PR is to fix an infinite loop that was seen in the wild when parsing DNS entries from a sample with private data logging enabled. This is due to a lack of verification of the IP type (4 vs 6) with no corresponding else block in the subsequent parsing loop. I also took the opportunity to do some minor cleanup, reducing some of the parsing down to one-liners with nom.

Copy link

google-cla bot commented Dec 2, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Reduces MAC address parsing into a single line with nom.

Should we verify the size of the input/number of items joined?
Adding the `verify` combinator prevents us from getting stuck in a loop,
since there is no `else` condition. This has been seen in the wild.
@dgmcdona dgmcdona force-pushed the dgmcdona/dns_infinite_loop_fix branch from c75e1b0 to 12d5d19 Compare December 2, 2024 16:13
@puffyCid
Copy link
Collaborator

puffyCid commented Dec 3, 2024

thanks for the fix!

@puffyCid puffyCid merged commit fcb4095 into mandiant:main Dec 3, 2024
4 checks passed
@puffyCid puffyCid mentioned this pull request Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants